<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jstl/core"
      xmlns:s="http://jboss.com/products/seam/taglib"
      xmlns:a="http://richfaces.org/a4j"
      xmlns:r="http://richfaces.org/rich"
      xmlns:m="http://www.caradvert.com/main">

<ui:component>

    <c:set var="color" value="#{advert.status eq 'APPROVED' ? 'green' : (advert.status eq 'PENDING' ? 'coral' : '#c70404')}"/>
    <c:set var="caption" value="#{advert.status eq 'APPROVED' ? labels['APPROVED'] : (advert.status eq 'PENDING' ? labels['PENDING'] : labels['REJECTED'])}"/>
    
    <table class="fullWide" cellpadding="0" cellspacing="0">
        <tr>
            <td>&#160;</td>
            <td style="background:#{color};color:white;width:100px;font-size:8pt;">
                #{caption}
            </td>
        </tr>
        <tr>
            <td colspan="2" style="background:#{color};padding:2px;">
                <div class="viewAdvert">
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <td >
                                <h:outputLink  style="display:block;width:#{config.imageConfig.previewWidth}px;height:#{config.imageConfig.previewHeight}px;"
                                               value="#{ctxPath}/content/pages/mymenu/sellAdvertDetails.xhtml?advert-id=#{advert.id}" title="#{labels['REVIEW']}">
                                    <h:graphicImage style="border-style:none;" rendered="#{not empty advert.images[0]}" url="#{config.imageConfig.uploadedUri}/#{advert.images[0].id}_preview.jpg"/>
                                    <h:graphicImage style="border-style:none;" rendered="#{empty advert.images[0]}" url="/resources/images/car_preview.jpg"/>
                                </h:outputLink>
                            </td>
                            <td valign="top" width="100%;">
                                <table style="width:100%;">
                                    <tr style="height:20px;font-size:7pt;font-weight:bold;vertical-align:top;color:gray;">
                                        <td colspan="3" style="padding-right:5px;" class="rj">
                                            <h:outputText value="#{advert.advertDate}">
                                                <f:convertDateTime pattern="dd.MM.yyyy"/>
                                            </h:outputText>
                                        </td>
                                    </tr>
                                    <tr class="cj">
                                        <td style="width:150px;">
                                            <table style="width:100%;padding-left:10px;">
                                                <tr>
                                                    <td style="font-weight:bold;" class="cj">
                                                        <h:panelGroup rendered="#{not empty advert.vehicle.brand}">
                                                            #{advert.vehicle.brand.name} #{advert.vehicle.model.name}
                                                        </h:panelGroup>
                                                        <h:panelGroup rendered="#{empty advert.vehicle.brand}">
                                                            #{advert.vehicle.brandName} #{advert.vehicle.modelName}
                                                        </h:panelGroup>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                        <td valign="middle">
                                            <table style="width:100%;">
                                                <tr>
                                                    <td>
                                                        <form action="#{ctxPath}/content/pages/mymenu/sellAdvertDetails.xhtml" method="get">
                                                            <input type="hidden" name="advert-id" value="#{advert.id}"/>
                                                            <input type="submit" value="#{labels['REVIEW']}" class="button"/>
                                                        </form>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <h:form>
                                                            <h:commandButton value="#{labels['DELETE']}" styleClass="button" style="color:#c70404;font-weight:bold;"
                                                                             action="#{viewAdvertsBean.removeAdvert(advert.id)}"
                                                                             onclick="return confirm('#{labels['DELETE_CONFIRM']}')"/>
                                                        </h:form>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="height:5px;"/>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <h:panelGroup rendered="#{advert.status eq 'REJECTED'}">
                                        <tr>
                                            <td class="lj" colspan="2" style="color:#c70404;font-size:8pt;padding:5px 20px 5px 5px;">
                                                <b>#{labels['REJECT_REASON']}:</b> #{advert.rejectReason}
                                            </td>
                                        </tr>
                                    </h:panelGroup>
                                </table>
                            </td>
                        </tr>
                    </table>
                </div>
            </td>
        </tr>
    </table>


</ui:component>
</html>